/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.hycreate.platform.modules.crm.business;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hycreate.platform.common.persistence.Page;
import com.hycreate.platform.common.service.CrudService;
import com.hycreate.platform.common.utils.IdGen;

/**
 * 商机录入Service
 * @author zyc
 * @version 2016-12-03
 */
@Service
@Transactional(readOnly = true)
public class CustomerService extends CrudService<CustomerDao, Customer> {

	public Customer get(String id) {
		return super.get(id);
	}
	
	public List<Customer> findList(Customer customer) {
		return super.findList(customer);
	}
	
	public Customer findMyList(String name) {
		return dao.findMyList(name);
	}
	
	
	
	public Page<Customer> findPage(Page<Customer> page, Customer customer) {
		return super.findPage(page, customer);
	}
	
	@Transactional(readOnly = false)
	public void save(Customer customer) {
		super.save(customer);
		String trade = customer.getTrade();
		//行业以逗号隔开,此处根据逗号得到该客户的所有行业并保存
		if(trade != null && trade != ""){
			String[] i_id = trade.split(",");
			//customer = dao.findMyList(customer.getName());
			for(int i=0;i<i_id.length;i++){
				dao.insertTrade(IdGen.uuid(),customer.getId(),i_id[i]);
			}
		}
	}
	
	@Transactional(readOnly = false)
	public void delete(Customer customer) {
		super.delete(customer);
	}
	
	
}